const Mock = require('mockjs');

const customerTypes = ['公司盘', '个人盘'];
const flowStatus = ['被退回', '审批中', '已通过'];
const status = ['挂起', '正常', '作废'];
const workOrderTypes = ['新安装', '上刊', '下刊', '巡检', '维修', '换画', '中间监播'];
const workOrderExeStatus = ['未执行', '执行中', '已完成', '手动关闭', '已过期'];

const data = Mock.mock({
	'items|10': [{
		id: '@id',
		customer_name: '@ctitle(2,6)公司',
		'customer_type_name|1': customerTypes,
		customer_maintenance: '@cname()',
		'customer_flow_status_name|1': flowStatus,
		customer_finished: '@float(1000,80000,0,2)',
		customer_total: '@float(80000,99000,0,2)',
		
		'contract_list|1-3': [{
			id: '@id',
			contract_num: 'XSHT202200@integer(10,99)',
			'contract_type_name|1': ['原始合同', '补充协议'],
			'contract_status_name|1': status,
			'contract_flow_status_name|1': flowStatus,
			contract_date: '@date("yyyy.MM.dd") - @date("yyyy.MM.dd")',
			contract_finished: '@float(1000,20000,0,2)',
			contract_discounted_price: '@float(20000,21000,0,2)',
			
			'bill_sale_list|0-6': [{
				id: '@id',
				'bill_sale_type_name|1': ['换画', '变更', '普通'],
				'bill_sale_status_name|1': status,
				'bill_sale_flow_status_name|1': flowStatus,
				bill_sale_date: '@date("yyyy.MM.dd") - @date("yyyy.MM.dd")',
				bill_sale_execute_amount: '@float(100,10000,0,2)',
				
				bill_market_has: true,
				bill_market_id: '@id',
				'bill_market_type_name|1': ['换画', '普通'],
				'bill_market_flow_status_name|1': flowStatus,
				bill_market_link_generated: '@boolean',
				bill_market_shoot_requirement_confirmed: '@boolean',
				bill_market_designed: '@boolean',
				bill_market_customer_confirmed: '@boolean',
				
				bill_ad_make_has: '@boolean',
				bill_ad_make_id: '@id',
				'bill_ad_make_type_name|1': ['换画', '普通'],
				'bill_ad_make_flow_status_name|1': flowStatus,
				bill_ad_make_dis_supplier: '@integer(2,3)',
				bill_ad_make_gen_link: '@integer(1,2)',
				bill_ad_make_supplier_confirm: '@integer(0,1)',
				
				work_order_distributed: '@boolean',
				work_order_distributed_finished: '@boolean',
				'work_order_list|0-4':[{
					id: '@id',
					work_order_name: '@ctitle(2,5)工单 @date("yyyy.MM.dd") - @date("yyyy.MM.dd")',
					'work_order_type_name|1': workOrderTypes,
					'work_order_status_name|1': status,
					'work_order_exe_status_name|1': workOrderExeStatus,
					work_order_installed_to_check_num: '@integer(0, 20)',
					work_order_installed_passed_num: '@integer(0, 100)',
					work_order_total_num: '@integer(120, 170)',
				}],
				
				broadcast_send: '@boolean',
				settle_material_upload: '@boolean',
				invoice_make_out: '@boolean',
				payment_receive: '@boolean',
			}]
		}]
	}]
})

module.exports = [{
	url: '/web/business_flow/customer_list',
	type: 'get',
	response: config => {
		const items = data.items
		return {
			code: 200,
			data: {
				total: 103,
				records: items
			}
		}
	}
}]
